var http = require("http");
var url = require("url");

function start(route, handle){
	function onRequest(request,response){
		var pathname = url.parse(request.url).pathname;
		// var para = url.parse(request.url).query; 

		// console.log("Request for "+pathname+" received.");
		// console.log("para: "+ para);
		

		// response.writeHead(200,{"Content-Type":"text/plain"});
		// var content = route(pathname,handle);
		// response.write(content);
		// response.end();

		route(pathname, handle,  response);
	}
	http.createServer(onRequest).listen(8888);
	console.log("Server has started.\n");
}


exports.start = start;